package com.zmn.oms.common.constant;

import com.google.common.collect.Lists;
import com.zmn.common.dictionary.DictModel;

import java.util.List;

/**
 * @ClassName OrderPostConsts
 * @Description 快递信息常量
 * @Author xiaofei
 * @Date 2020/8/11 13:29
 * @Version 1.0
 */
public class OrderPostConsts {


    /**
     * oms快递邮寄状态 已发货，运输中，派件中，已签收，签收异常，退回，异常
     */
    public final static int ORDERPOST_STATUS_DELIVERED = 1; //已发货
    public final static int ORDERPOST_STATUS_SHIPMENT = 2; //派件中
    public final static int ORDERPOST_STATUS_TRANSIT = 3; //运输中
    public final static int ORDERPOST_STATUS_RECEIVED = 4; //已签收
    public final static int ORDERPOST_STATUS_RECEIVE_ABNORMAL = 5; //签收异常
    public final static int ORDERPOST_STATUS_SEND_BACK = 6; //退回
    public final static int ORDERPOST_STATUS_ABNORMAL = 7; //异常

    /**
     * 快递货物类型
     */
    public final static int EXPRESS_ITEMTYPE_NEW_MACHINE = 1; //新机
    public final static int EXPRESS_ITEMTYPE_NEW_FITTINGS = 2; //配件-新件
    public final static int EXPRESS_ITEMTYPE_OLD_FITTINGS = 3; //配件-旧件

    public final static int SOURCE_TYPE_PLATFORM = 1; // 平台快递
    public final static int SOURCE_TYPE_CHANNEL = 2;  // 渠道快递


    /**
     * 获取快递货物类型
     *
     * @return
     */
    public static List<DictModel> getExpressItemTypeList() {
        List<DictModel> items = Lists.newArrayList();
        items.add(new DictModel(EXPRESS_ITEMTYPE_NEW_MACHINE, "新机"));
        items.add(new DictModel(EXPRESS_ITEMTYPE_NEW_FITTINGS, "配件-新件"));
        items.add(new DictModel(EXPRESS_ITEMTYPE_OLD_FITTINGS, "配件-旧件"));
        return items;
    }

    /**
     * 获取快递类型名称
     *
     * @return String
     */
    public static String getExpressItemTypeName(Integer itemType) {

        switch (itemType) {
            case EXPRESS_ITEMTYPE_NEW_MACHINE:
                return "新机";
            case EXPRESS_ITEMTYPE_NEW_FITTINGS:
                return "配件-新件";
            case EXPRESS_ITEMTYPE_OLD_FITTINGS:
                return "配件-旧件";
            default:
                return "";
        }
    }

    /**
     * 获取快递起源类型名称
     * @param sourceTypeCode
     * @return
     */
    public static String getSourceTypeName(Integer sourceTypeCode) {
        if (sourceTypeCode == null) {
            return "";
        }

        switch (sourceTypeCode.intValue()) {
            case SOURCE_TYPE_PLATFORM:
                return "平台快递";
            case SOURCE_TYPE_CHANNEL:
                return "渠道快递";
            default:
                return "";
        }
    }

    /**
     * 获取快递状态
     *
     * @return
     */
    public static List<DictModel> getExpressStatusList() {
        List<DictModel> items = Lists.newArrayList();
        items.add(new DictModel(ORDERPOST_STATUS_DELIVERED, "已揽件"));
        items.add(new DictModel(ORDERPOST_STATUS_SHIPMENT, "派件中"));
        items.add(new DictModel(ORDERPOST_STATUS_TRANSIT, "运输中"));
        items.add(new DictModel(ORDERPOST_STATUS_RECEIVED, "已签收"));
        items.add(new DictModel(ORDERPOST_STATUS_RECEIVE_ABNORMAL, "签收异常"));
        items.add(new DictModel(ORDERPOST_STATUS_SEND_BACK, "退回"));
        items.add(new DictModel(ORDERPOST_STATUS_ABNORMAL, "异常"));
        return items;
    }

    /**
     * 转化快递状态为啄木鸟状态
     *
     * @return
     */
    public static Integer getZmnPostStatus(Integer status) {
        if (status == null) {
            return null;
        }
        Integer postStatus = null;
        switch (status) {
            case 0:
                postStatus = ORDERPOST_STATUS_TRANSIT;
                break;
            case 1:
                postStatus = ORDERPOST_STATUS_DELIVERED;
                break;
            case 2:
                postStatus = ORDERPOST_STATUS_ABNORMAL;
                break;
            case 3:
                postStatus = ORDERPOST_STATUS_RECEIVED;
                break;
            case 4:
                postStatus = ORDERPOST_STATUS_SEND_BACK;
                break;
            case 5:
                postStatus = ORDERPOST_STATUS_SHIPMENT;
                break;
            case 6:
                postStatus = ORDERPOST_STATUS_SEND_BACK;
                break;
            case 7:
                postStatus = ORDERPOST_STATUS_SHIPMENT;
                break;
            case 10:
                postStatus = ORDERPOST_STATUS_TRANSIT;
                break;
            case 11:
                postStatus = ORDERPOST_STATUS_TRANSIT;
                break;
            case 12:
                postStatus = ORDERPOST_STATUS_TRANSIT;
                break;
            case 13:
                postStatus = ORDERPOST_STATUS_TRANSIT;
                break;
            case 14:
                postStatus = ORDERPOST_STATUS_RECEIVE_ABNORMAL;
                break;
            default:
                return null;
        }
        return postStatus;
    }

    /**
     * 获取快递状态名称
     *
     * @return
     */
    public static String getPostStatusName(Integer status) {
        if (status == null) {
            return null;
        }
        String statusName = "";
        switch (status) {
            case ORDERPOST_STATUS_DELIVERED:
                statusName = "已揽件";
                break;
            case ORDERPOST_STATUS_SHIPMENT:
                statusName = "派件中";
                break;
            case ORDERPOST_STATUS_TRANSIT:
                statusName = "运输中";
                break;
            case ORDERPOST_STATUS_RECEIVED:
                statusName = "已签收";
                break;
            case ORDERPOST_STATUS_RECEIVE_ABNORMAL:
                statusName = "签收异常";
                break;
            case ORDERPOST_STATUS_SEND_BACK:
                statusName = "退回";
                break;
            case ORDERPOST_STATUS_ABNORMAL:
                statusName = "异常";
                break;
        }
        return statusName;
    }

}
